/**
 * 重写 2018年5月17日 14:28:41
 */
var tableEle;//电表
var activebuildingID = '';//选中楼宇ID
var BUSINESS_ID = '';//选中商圈ID
var code = '';//查询条件编号
var today = DateUtils.dateFormat(new Date(), "yyyy-MM"); // 今天的日期
var displaySwitch = 0;//显示隐藏开关
var $;
var layer;
var table;
layui.use(['jquery', 'table', 'laydate', 'form', 'layer', 'element','treeGrid'], function () {
    table = layui.table;
    layer = layui.layer;
    treeGrid = layui.treeGrid;
    var form = layui.form;
    var element = layui.element;
    $ = layui.jquery;
    var laydate = layui.laydate;
    //执行一个laydate实例
    laydate.render({
        elem: '#eledate'
        , type: 'month'
        , trigger: 'click'
        , btns: ['now', 'confirm']
        , done: function (value, date, endDate) {
            $("#eledate").val(value);
            search(0);
        }
    });
    $("#eledate").val(today);
    activebuildingID = QueryUtils.GetQueryString('activebuildingID');
    BUSINESS_ID=QueryUtils.GetQueryString("activebusinessID");
    <!--**********************水电表管理*************************-->
    //电表展示已知数据
    tableEle = treeGrid.render({
        elem: '#dbgl'
        , url: '/hydropowerdetail/list'
        , where: {TYPE: 'b938139a48ed4344a11a7180b48eede6'}
        , cellMinWidth: 100
        , treeId: 'ID'//树形id字段名称
        , treeUpId: 'PID'//树形父id字段名称
        , treeShowName: 'CODE'//以树形式显示的字段
        , cols: [[
            /*{type: 'checkbox'},*/
            {checkbox: true, LAY_CHECKED: true} //默认全选
            ,{field: 'CODE', width: '300', title: '电表编号'}
            , {field: 'NAME', width: '300', title: '电表位置', templet: '#nameTpl'}
            , {field: 'ATTR', width: '100', title: '电表属性', align: 'center', templet: '#attrTpl'}
            , {field: 'CUR_DEGREES', title: '本次读数',edit: 'text', width: 150, style: 'cursor: pointer;', templet: '#emptyTemp'}
            , {field: 'CUR_DATE', title: '本次读表日期', width: 150, templet: '#curDate',edit: 'text'}
            , {fixed: 'right', title: '操作', width: 80, align: 'right', toolbar: '#dbglBar'}
        ]]
        , id: 'ET'
        , page: true
        , limit: 10
        , height: 400
    });
    //打开抄表记录页面
    treeGrid.on('tool(power)', function (obj) {
        var data = obj.data;
        //生成账单
        if (obj.event === 'genRecord') {
            parent.layer.open({
                type: 2
                , zIndex: 1001
                ,closeBtn :0//不显示关闭按钮
                , anim: 7
                , offset: 'r'
                , shadeClose: true
                , area: ['70%', '100%']
                , content: '../../../webhtml/hydropower/eletric_info.html?CODE='+data.ID+''//这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
                , yes: function (index, layero) {
                    //do something
                    //layer.closeAll();
                    var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                    parent.layer.close(index);
                }
            });
        }
    });
    var active={

    }

});
